home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…eptember: Technology Seed / September 98 ADC Seed CD.toast / FireWire 1.1 DR2 SDK / Source / OpenTransport / FWOTDriver / DLPIRoutines.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-15  |  7.0 KB  |  199 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DLPIRoutines.h
  3.  
  4.     Contains:    This file contains the defines necessary for the STREAMS environment.
  5.  
  6.     Written by:    
  7.  
  8.     Copyright:    © 1994, 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.        <FW2>     6/20/96    ES        Made this look more like a .i generated interface.
  13.          <1>     3/27/96    ES        first checked in
  14.  
  15.     To Do:
  16. */
  17.  
  18.  
  19. #ifndef __DLPIROUTINES__
  20. #define __DLPIROUTINES__
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. #if PRAGMA_IMPORT_SUPPORTED
  27. #pragma import on
  28. #endif
  29.  
  30. #if PRAGMA_ALIGN_SUPPORTED
  31. #pragma options align=mac68k
  32. #endif
  33.  
  34. //-----------------------------------------------------------------------------------------
  35. // bit definitions for various flags used in the per stream data structure (streamFlags)
  36. //-----------------------------------------------------------------------------------------
  37. enum DLPIStreamFlags
  38.     {
  39.     kAutoXID                =    0x00000001,
  40.     kAutoTest                =    0x00000002,
  41.     kSnapStream                =    0x00000004,
  42.     kAcceptMulticasts        =    0x00000008,
  43.     kAcceptAll8022Packets    =    0x00000010,
  44.     kWriteRawPackets        =    0x00000020,
  45.     kReadRawPackets            =    0x00000040
  46.     };
  47.  
  48. //-----------------------------------------------------------------------------------------
  49. // Used to register Group SAP addresses
  50. //-----------------------------------------------------------------------------------------
  51. #define kGroupSAPMapSize    128/32        // number of 32 values we need for 128 bits    
  52. #define kGSshift            6
  53. #define kGSmask                0x1F
  54.  
  55. //-----------------------------------------------------------------------------------------
  56. // Internal Return codes for DLPI
  57. //-----------------------------------------------------------------------------------------
  58.  
  59. enum DLPIInternalCodes        
  60.     {
  61.     kdlpiDONE            = 1,
  62.     kdlpiRETRY            = 2
  63.     };
  64.  
  65. //-----------------------------------------------------------------------------------------
  66. // Timer Message Types
  67. //-----------------------------------------------------------------------------------------
  68.  
  69. enum TimerMessageTypes        
  70.     {
  71.     kEnableQueueTimerMsg    = 1
  72.     };
  73.  
  74. //-----------------------------------------------------------------------------------------
  75. // Write Scheduler Types
  76. //-----------------------------------------------------------------------------------------
  77.  
  78. enum DLPISchedulerType        
  79.     {
  80.     kdlpiBufcallType    = 1
  81.     };
  82.  
  83. //-----------------------------------------------------------------------------------------
  84. // Packet Types
  85. //-----------------------------------------------------------------------------------------
  86. enum PacketTypes        
  87.     {
  88.     kPktDIX                = 0,
  89.     kPkt8022SAP            = 1,
  90.     kPkt8022GroupSAP    = 2,
  91.     kPkt8022SNAP        = 3,
  92.     kPktIPX                = 4,
  93.     kPktUnknown            = 5
  94.     };
  95.  
  96. //-----------------------------------------------------------------------------------------
  97. // Ethernet length constants
  98. //-----------------------------------------------------------------------------------------
  99. #define kEnetPhysicalAddressLength     k48BitAddrLength    // 6 bytes for ethernet
  100. #define kEnetAndSAPAddressLength     kEnetPhysicalAddressLength + k8022DLSAPLength
  101. #define kMaxBoundAddrLength         6 + 2 + 5            // addr + sap + snap
  102.  
  103. //-----------------------------------------------------------------------------------------
  104. // New structures
  105. //-----------------------------------------------------------------------------------------
  106. struct T8022AddressStruct
  107.     {
  108.     UInt8            fHWAddr[k48BitAddrLength];
  109.     UInt16            fSAP;
  110.     UInt8            fSNAP[k8022SNAPLength];
  111.     };
  112. typedef struct T8022AddressStruct T8022AddressStruct;
  113.  
  114. //-----------------------------------------------------------------------------------------
  115. // One structure per stream for our dlpi
  116. //-----------------------------------------------------------------------------------------
  117.  
  118. struct DLPIStream 
  119.     {
  120.     struct DLPIStream     *nextStream;                // queue pointer for active streams 
  121.     struct DLPIStream     *rxPacketLink;                // streams that want a received packet 
  122.     queue_t                *readQueue;                    
  123.     UInt32                dlpiState;                    
  124.     UInt32                timeoutID;                    // id for bufcalls and timeouts 
  125.     UInt16                idType;                        // type of id (bufcall or timeout)
  126.     UInt16                minorDevice;
  127.     UInt16                dlsap;
  128.     UInt32                group_sap[kGroupSAPMapSize];
  129.     UInt32                streamFlags;                // 32 1 bit flags for the stream
  130.     QHdr                multicastQueue;
  131.     UInt8                snap[k8022SNAPLength];
  132.     mblk_t                *bufferTimerMsg;
  133.     };
  134.  
  135. typedef struct DLPIStream DLPIStream;
  136.  
  137. //-----------------------------------------------------------------------------------------
  138. // Function Prototypes
  139. //-----------------------------------------------------------------------------------------
  140.  
  141. SInt32 GetAddressType(UInt8 *);
  142. SInt32 BindTheStream(DLPIStream *, mblk_t *);
  143. SInt32 DoEnableMulticast(DLPIStream *, mblk_t *);
  144. SInt32 DoErrorAck(DLPIStream *, mblk_t *, UInt32, UInt32, UInt32);
  145. void FindStreamForReceivedPacket(DLPIStream *, mblk_t *);
  146. SInt32 DoGeneralInfo(DLPIStream *);
  147. void DoOKAck(DLPIStream *, mblk_t *, UInt32);
  148. SInt32 DoPhysicalAddressAck(DLPIStream *,mblk_t *);
  149. SInt32 SubsBindTheStream(DLPIStream *, mblk_t *);
  150. SInt32 UnSubsBindTheStream(DLPIStream *, mblk_t *);
  151. SInt32 SendTestPacket(DLPIStream *, mblk_t *, UInt8);
  152. Boolean TestGroupSAP(DLPIStream *, UInt8);
  153. SInt32 UnBindTheStream(DLPIStream *, mblk_t *);
  154. void DoUnitData(DLPIStream *, mblk_t *);
  155. SInt32 DoXID(DLPIStream *, mblk_t *, UInt8);
  156. SInt32 DoDisableMulticast(DLPIStream *, mblk_t *);
  157. mblk_t *BuildPacketHeader(DLPIStream *, mblk_t *, UInt8 *, UInt32, UInt8, UInt8,Boolean);
  158. SInt32 DoSetPhysicalAddress(DLPIStream *theStream, mblk_t *mp);
  159. SInt32 DoStatisticsAck(DLPIStream *theStream, mblk_t *mp); 
  160.  
  161.  
  162. mblk_t *BuildBindAck(DLPIStream *, UInt16);
  163. void BuildXidTestConfirmIndication(DLPIStream *theStream, mblk_t *mp, UInt16 destAddrLength, UInt16 headerHideLength);
  164. void ClearGroupSAP(DLPIStream *, UInt8);
  165. void EnableWriteQueue(long);
  166. SInt32 FindSnap(DLPIStream *, UInt8 *, SInt32);
  167. void SetGroupSAP(DLPIStream *, UInt8);
  168. mblk_t *BuildSubsBindAck(DLPIStream *, UInt8 *, SInt32);
  169. void DoTestResponse(DLPIStream *, mblk_t *);
  170. void DoUdError(DLPIStream *, UInt8 *, UInt32, UInt32, UInt32);
  171. void DoWriteScheduler(DLPIStream *, SInt32);
  172. void DoXidResponse(DLPIStream *, mblk_t *);
  173. UInt16 ClassifyPacketType(UInt16 primarySAP, UInt16 secondarySAP);
  174. mblk_t *ReuseMessageBlock(mblk_t *mp,UInt16 dataSizeNeeded);
  175. void BuildRxDestSrcHeader(T8022FullPacketHeader *packetHeader,T8022AddressStruct *destAddr,T8022AddressStruct *srcAddr,UInt32 dlsap_length);
  176. Boolean AreAllStreamsUnbound(void);
  177. void AddXIDInfoToPacketData(DLPIStream *theStream, mblk_t *headerMB, mblk_t *dataMB);
  178. void BuildUnitDataIndication(DLPIStream *theStream, mblk_t *mp, UInt16 destAddrLength, UInt16 headerHideLength);
  179. Boolean CheckAddressMatch(UInt8 *, UInt8 *, SInt32);
  180. void HandleReceivedPacket(DLPIStream *theStream, mblk_t *mp,UInt16 packetType);
  181. void ExtractSAPValues(T8022FullPacketHeader *fullpkt, UInt16 *sourceSAP, UInt16 *destSAP);
  182. mblk_t *BuildTxPacketHeader(DLPIStream *theStream, mblk_t *mp, Boolean forFastPathOnly);
  183. mblk_t *IsAddressRegistered(QHdr *multicastQueue,UInt8 *reqaddr, Boolean dequeueBlock,UInt16 interruptMask);
  184. UInt16 ClassifyRxPacket(mblk_t *thePacket);
  185.  
  186. #if PRAGMA_ALIGN_SUPPORTED
  187. #pragma options align=reset
  188. #endif
  189.  
  190. #if PRAGMA_IMPORT_SUPPORTED
  191. #pragma import off
  192. #endif
  193.  
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197.  
  198. #endif /* __DLPIROUTINES__ */
  199.